package com.tj.bo.payment.server.services;

import com.tj.bo.payment.client.PayQueryService;
import com.tj.bo.payment.client.enums.PayOrderStatusEnum;
import com.tj.bo.payment.client.enums.PayOrderTypeEnum;
import com.tj.bo.payment.client.vo.PaymentChannelVO;
import com.tj.bo.payment.server.dao.PaymentOrderDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.Collections;
import java.util.List;

/**
 * @author ZhangChao
 * @since 2021/7/16
 */
@Service
public class PayQueryServiceImpl implements PayQueryService {
    @Autowired
    private PaymentConfig paymentConfig;
    private List<PaymentChannelVO> list;
    @Autowired
    private PaymentOrderDao paymentOrderDao;

    @PostConstruct
    public void init(){
        PaymentChannelVO paymentChannelVO = new PaymentChannelVO();
        paymentChannelVO.setCode(paymentConfig.getChannelCode());
        paymentChannelVO.setName(paymentConfig.getChannelName());
        paymentChannelVO.setServerFeeRate(paymentConfig.getServiceFeeRate());
        list = Collections.singletonList(paymentChannelVO);
    }
    @Override
    public List<PaymentChannelVO> getPaymentChannels() {
        return list;
    }

    @Override
    public List<String> queryPaymentOrderCodes(PayOrderStatusEnum payOrderStatusEnum, PayOrderTypeEnum payOrderTypeEnum) {
        return paymentOrderDao.queryOrderCode(payOrderStatusEnum.getCode(), payOrderTypeEnum.getCode());
    }
}
